home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / GLUT-3.7 / LIB / GLSMAP / glsmapint.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-12  |  2.2 KB  |  103 lines

  1. #ifndef __glsmapint_h__
  2. #define __glsmapint_h__
  3.  
  4. /* Copyright (c) Mark J. Kilgard, 1998. */
  5.  
  6. /* This program is freely distributable without licensing fees 
  7.    and is provided without guarantee or warrantee expressed or 
  8.    implied. This program is -not- in the public domain. */
  9.  
  10. #include <GL/glsmap.h>
  11.  
  12. enum { X = 0, Y = 1, Z = 2 };
  13.  
  14. #define INITFACE(mesh) \
  15.     int steps = mesh->steps; \
  16.     int sqsteps = mesh->steps * mesh->steps
  17.  
  18. #define FACE(side,y,x) \
  19.     mesh->face[(side)*sqsteps + (y)*steps + (x)]
  20.  
  21. #define FACExy(side,i,j) \
  22.     (&FACE(side,i,j).x)
  23.  
  24. #define FACEst(side,i,j) \
  25.     (&FACE(side,i,j).s)
  26.  
  27. #define INITBACK(mesh) \
  28.     int allrings = mesh->rings + mesh->edgeExtend; \
  29.     int ringedspokes = allrings * mesh->steps
  30.  
  31. #define BACK(edge,ring,spoke) \
  32.     mesh->back[(edge)*ringedspokes + (ring)*mesh->steps + (spoke)]
  33.  
  34. #define BACKxy(edge,ring,spoke) \
  35.     (&BACK(edge,ring,spoke).x)
  36.  
  37. #define BACKst(edge,ring,spoke) \
  38.     (&BACK(edge,ring,spoke).s)
  39.  
  40. typedef struct _STXY {
  41.     GLfloat s, t;
  42.     GLfloat x, y;
  43. } STXY;
  44.  
  45. typedef struct _SphereMapMesh {
  46.  
  47.     int refcnt;
  48.  
  49.     int steps;
  50.     int rings;
  51.     int edgeExtend;
  52.  
  53.     STXY *face;
  54.     STXY *back;
  55.  
  56. } SphereMapMesh;
  57.  
  58. struct _SphereMap {
  59.  
  60.     /* Shared sphere map mesh vertex data. */
  61.     SphereMapMesh *mesh;
  62.  
  63.     /* Texture object ids. */
  64.     GLuint smapTexObj;
  65.     GLuint viewTexObjs[6];
  66.     GLuint viewTexObj;
  67.  
  68.         /* Flags */
  69.         SphereMapFlags flags;
  70.  
  71.     /* Texture dimensions must be a power of two. */
  72.     int viewTexDim;  /* view texture dimension */
  73.     int smapTexDim;  /* sphere map texture dimension */
  74.  
  75.     /* Viewport origins for view and sphere map rendering. */
  76.     int viewOrigin[2];
  77.     int smapOrigin[2];
  78.  
  79.     /* Viewing vectors. */
  80.     GLfloat eye[3];
  81.     GLfloat up[3];
  82.     GLfloat obj[3];
  83.  
  84.     /* Projection parameters. */
  85.     GLfloat viewNear;
  86.     GLfloat viewFar;
  87.  
  88.     /* Rendering callbacks. */
  89.     void (*positionLights)(int view, void *context);
  90.     void (*drawView)(int view, void *context);
  91.  
  92.     /* Application specified callback data. */
  93.     void *context;
  94.  
  95. };
  96.  
  97. /* Library internal routines. */
  98. extern void __smapDrawSphereMapMeshSide(SphereMapMesh *mesh, int side);
  99. extern void __smapDrawSphereMapMeshBack(SphereMapMesh *mesh);
  100. extern void __smapValidateSphereMapMesh(SphereMapMesh *mesh);
  101.  
  102. #endif /* __glsmapint_h__ */
  103.